package com.youth.mapper;

import com.youth.entity.po.OrderItem;
import com.youth.entity.vo.OrderItemVO;
import org.apache.ibatis.annotations.*;


@Mapper
public interface IOrderItemMapper {

    int deleteByPrimaryKey(String id);

    @Insert("insert into tb_order_item (t_c_id,order_id,num,title,price,total_fee,pic_path) value(#{tCId},#{orderId},#{num},#{title},#{price},#{totalFee},#{picPath})")
    @Options(useGeneratedKeys = true, keyColumn = "id")
    int insert(OrderItem record);


    @Update("<script>" +
            "update  tb_order_item " +
            "set order_id=#{orderId}" +
            "<if test='num != null'> " + " ,num =#{num}" +
            "</if>" +
            "<if test='title != null'> " + ", title =#{title}" +
            "</if>" +
            "<if test='price != null'> " + ", price =#{price}" +
            "</if>" +
            "<if test='totalFee != null'> " + ", total_fee =#{totalFee}" +
            "</if>" +
            "<if test='picPath != null'> " + ", pic_path =#{picPath}" +
            "</if>" +
            "  where order_id=#{orderId}" +
            "</script>")
    int updateByOrderId(OrderItem record);


    @Select("select i.t_c_id,i.num,i.title,i.price,i.total_fee,i.pic_path from tb_order_item as i where order_id=#{orderId}")
    OrderItemVO getOrderItemById(@Param("orderId") String orderId);

}